package com.maidshop.maid.controller;

import com.maidshop.common.core.controller.BaseController;
import com.maidshop.common.core.page.TableDataInfo;
import com.maidshop.maid.domain.Maid;
import com.maidshop.maid.domain.dto.MaidDto;
import com.maidshop.maid.domain.vo.MaidVo;
import com.maidshop.maid.service.MaidService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/maid")
public class MaidController extends BaseController {

    @Resource
    private MaidService maidService;

    @GetMapping("/list")
    public TableDataInfo list(MaidVo vo) {
        startPage();
        List<MaidDto> list = maidService.list(vo);
        return getDataTable(list);
    }

    @PostMapping("/insertOrUpdate")
    public void add(@RequestBody Maid maid) {
        if (maid.getId() == null) {
            // 保存女仆信息
            maidService.saveMaid(maid);
        } else {
            // 更新女仆信息
            maidService.updateMaid(maid);
        }
    }

}
